package com.example.layoutdesignnet2012;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {
     ImageView iv ;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.my_view_layout);
       Button bt2 = findViewById(R.id.bt2);
       Button change_img_bt= findViewById(R.id.change_img_bt);
       iv =findViewById(R.id.iv);
       //监听change_img_bt按钮
        change_img_bt.setOnClickListener(this);

       //设置bt2点击监听
       bt2.setOnClickListener(new View.OnClickListener() {
           @Override
           public void onClick(View v) {
               Log.i("TAG","bt2被点击了~~~");
           }
       });

    }

    //点击事件
    public  void clickTest(View view){
        Log.i("TAG","我被点击了~");
    }

    @Override
    public void onClick(View v) {
        if (v.getId()==R.id.change_img_bt){//如点击切换图按钮，实现一下逻辑
            iv.setImageResource(R.drawable.test2imge);
        }
    }
}